#include "MultiMedia.h"


MultiMedia::MultiMedia(void)
{
	this->type = "NULL";
	this->title = "NULL";
	this->author = "NULL";
	this->genre = "NULL";
	this->year = 0;
}

MultiMedia::MultiMedia( string type, string title, string author, string genre, int year )
{
	this->type = type;
	this->title = title;
	this->author = author;
	this->genre = genre;
	this->year = year;
}


MultiMedia::~MultiMedia(void)
{
	//cout << "Destruktor MultiMedia" << endl;
}


ostream &operator<<( ostream &out, const MultiMedia &multimedia )
{
	out << "(";
	out << multimedia.type << ",";
	out << multimedia.title << ",";
	out << multimedia.author << ",";
	out << multimedia.genre << ",";
	out << multimedia.year;
	out << ")" << endl;
	return out;
}


istream &operator>>( istream &in, MultiMedia &multimedia )
{
	char c;
	
	in >> c;
	std::getline( in, multimedia.type, ',' );
	in >> skipws;
	std::getline( in, multimedia.title, ',' );
	in >> skipws;
	std::getline (in, multimedia.author, ',' );
	in >> skipws;
	std::getline( in, multimedia.genre, ',' );
	in >> skipws;
	in >> multimedia.year;
	in >> skipws >> c;

	return in;
}

bool operator==( const MultiMedia &one, const MultiMedia &other )
{
	if( one.type == other.type )
	{
		if( one.title == other.title )
		{
			if( one.author == other.author )
			{
				if( one.genre == other.genre )
				{
					if( one.year == other.year )
					{
						return true;
					}
				}
			}
		}
	}
	return false;
}

bool operator!=( const MultiMedia &one, const MultiMedia &other )
{
	return !( one == other );
}

bool operator<( const MultiMedia &one, const MultiMedia &other )
{
	if( one.type < other.type )
		return true;
	else if( (one.type == other.type) && (one.author < other.author) )
		return true;
	else if( ( (one.type == other.type) && (one.author == other.author) ) && (one.year < other.year) )
		return true;
	else if( ( ((one.type == other.type) && (one.author == other.author) ) && (one.year == other.year) ) && (one.genre < other.genre) )
		return true;
	else if( ( (((one.type == other.type) && (one.author == other.author) ) && (one.year == other.year) ) && (one.genre == other.genre) ) &&  (one.title < other.title) )
		return true;
	else
		return false;
}
/*
bool operator<( const MultiMedia *one, const MultiMedia *other )
{
	if( one->type < other->type )
		return true;
	else if( (one->type == other->type) && (one->author < other->author) )
		return true;
	else if( ( (one->type == other->type) && (one->author == other->author) ) && (one->year < other->year) )
		return true;
	else if( ( ((one->type == other->type) && (one->author == other->author) ) && (one->year == other->year) ) && (one->genre < other->genre) )
		return true;
	else if( ( (((one->type == other->type) && (one->author == other->author) ) && (one->year == other->year) ) && (one->genre == other->genre) ) &&  (one->title < other->title) )
		return true;
	else
		return false;
}
*/

void MultiMedia::Print( ostream &out )
{
}

bool sort_pred( MultiMedia one, MultiMedia other )
{
	return (one.GetType() < other.GetType() );
}